{extend name="wap/b2c/base" /} 
{block name="resources"}
<link rel="stylesheet" type="text/css"
	href="__TEMP__/{$style}/public/css/member_address.css">
<style>
.head_right{
	position: absolute;
    top: 0;
    width: 80px;
    height: 44px;
    line-height: 44px;
    color: #333;
    text-align: center;
	right:0;
}
.head_right img{
	display:inline-block;
	height:20px;
	width:20px;
	margin-top:12px;
}
</style>
{/block} {block name="goodsHead"}
<section class="head">
	<a class="head_back" onclick="window.history.go(-1)"
		href="javascript:void(0)"><i class="icon-back"></i></a>
	<div class="head-title">推广二维码</div>
	<a class="head_right"  style="right:0;" href="APP_MAIN/Member/updateUserQrcodeTemplate.html?shop_id={$shop_id}">
		<img src="__TEMP__/{$style}/public/images/change.png"/>
		换一换
		</a>
</section>
{/block} {block name="main"}
<image class="shop-qrcode"src="APP_MAIN/Member/showUserQrcode?shop_id={$shop_id}" style="display:block;width:100%;margin-top:45px;">
{include file='wap/b2c/share'/}
{/block}
{block name="bottom"}{/block} 
 {block name="javascript"}
<script type="text/javascript">
	$(function(){
		//$(".shop-qrcode").height($(window).height()-45);
		$.ajax({
			type:"post",
			data : {"shop_id" : "{$shop_id}" , "flag" : "qrcode_my"},
			url : "APP_MAIN/member/getShareContents",
			success : function(data){
				//alert(JSON.stringify(data));
				//document.write(data.share_img);
				/* $("#share_title").val(data['share_title']);
				$("#share_desc").val(data['share_contents']);
				$("#share_url").val(data['share_url']);
				$("#share_img_url").val(data['share_img']);\ */
				wx.config({
					debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					appId: $("#appId").val(), // 必填，公众号的唯一标识
					timestamp: $("#jsTimesTamp").val(), // 必填，生成签名的时间戳
					nonceStr:  $("#jsNonceStr").val(), // 必填，生成签名的随机串
					signature: $("#jsSignature").val(),// 必填，签名，见附录1
					jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
				});
				wx.ready(function () {
				    var title = data['share_title'];
				    var share_contents = data['share_contents']+'\r\n';
				    var share_nick_name = data['share_nick_name']+'\r\n';
				    var desc2 = share_contents+ share_nick_name + "收藏热度：★★★★★";
					var url = data['share_url'];
					var img_url = data['share_img'];
					wx.onMenuShareAppMessage({
						title: title,
						desc: desc2,
						link: url,
						imgUrl: img_url,
						trigger: function (res) {
//							alert('用户点击发送给朋友');
						},
						success: function (res) {
							$.ajax({
								type : "post",
								url : "APP_MAIN/member/shareGivePoint",
								data : {
									"share" : true
								},
								success : function(data){
									
								}
							})
//			                alert('已分享');
			            },
			            cancel: function (res) {
			                //alert('已取消');
			            },
			            fail: function (res) {
			                //alert(JSON.stringify(res));
			            }
			        });

			    // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
			        wx.onMenuShareTimeline({
			            title: title,
			            link: url,
			            imgUrl: img_url,
			            trigger: function (res) {
			              // alert('用户点击分享到朋友圈');
			            },
			            success: function (res) {
			                //alert('已分享');
			            	$.ajax({
								type : "post",
								url : "APP_MAIN/member/shareGivePoint",
								data : {
									"share" : true
								},
								success : function(data){
									
								}
							})
			            },
			            cancel: function (res) {
			                //alert('已取消');
			            },
			            fail: function (res) {
			           //     alert(JSON.stringify(res));
			            }
			        });

			    // 2.3 监听“分享到QQ”按钮点击、自定义分享内容及分享结果接口
			        wx.onMenuShareQQ({
			            title: title,
			            desc: desc2,
			            link: url,
			            imgUrl: img_url,
			            trigger: function (res) {
			                //alert('用户点击分享到QQ');
			            },
			            complete: function (res) {
			                //alert(JSON.stringify(res));
			            },
			            success: function (res) {
			                //alert('已分享');
			            	$.ajax({
								type : "post",
								url : "APP_MAIN/member/shareGivePoint",
								data : {
									"share" : true
								},
								success : function(data){
									
								}
							})
			            },
			            cancel: function (res) {
			                //alert('已取消');
			            },
			            fail: function (res) {
			                //alert(JSON.stringify(res));
			            }
			        });

			    // 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口
			        wx.onMenuShareWeibo({
			            title: title,
			            desc: desc2,
			            link: url,
			            imgUrl: img_url,
			            trigger: function (res) {
			                //alert('用户点击分享到微博');
			            },
			            complete: function (res) {
			                //alert(JSON.stringify(res));
			            },
			            success: function (res) {
			                //alert('已分享');
			            	$.ajax({
								type : "post",
								url : "APP_MAIN/member/shareGivePoint",
								data : {
									"share" : true
								},
								success : function(data){
									
								}
							})
			            },
			            cancel: function (res) {
			                //alert('已取消');
			            },
			            fail: function (res) {
			                //alert(JSON.stringify(res));
			            }
			        });


			})
	
			}
		})
})
</script>
{/block}
